package com.dzl.userwx.service.impl;

import com.dzl.base.service.BaseServiceImpl;
import com.dzl.userwx.dao.WelfareUserOrganizationMapper;
import com.dzl.userwx.pojo.WelfareUserOrganization;
import com.dzl.userwx.pojo.query.UserOrganizationQuery;
import com.dzl.userwx.pojo.vo.WelfareUserOrganizationVo;
import com.dzl.userwx.service.WelfareUserOrganizationService;
import com.dzl.util.EmptyUtils;
import com.dzl.util.PasswordUtil;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户所属组织信息表(UserOrganization)表服务实现类
 * @author caobucao
 * @date 2021-09-07 16:02:28
 */
@Service
public class WelfareUserOrganizationServiceImpl extends BaseServiceImpl<WelfareUserOrganization> implements WelfareUserOrganizationService {

    @Autowired
    private WelfareUserOrganizationMapper mapper;

    @Override
    public List<Integer> selectUserIdListByIds(List<Integer> ids) {
        return mapper.selectUserIdListByIds(ids);
    }

    @Override
    public int deleteByIds(List<Integer> ids) {
        return mapper.deleteByIds(ids);
    }

    @Override
    public List<WelfareUserOrganizationVo> getOrganizationUserList(UserOrganizationQuery query) {
        PageHelper.startPage(query);
        List<WelfareUserOrganizationVo> list = mapper.getOrganizationUserList(query);
        for (WelfareUserOrganizationVo welfareUserOrganizationVo : list) {
            if (EmptyUtils.isNotEmpty(welfareUserOrganizationVo) && EmptyUtils.isNotEmpty(welfareUserOrganizationVo.getPassword())) {
                welfareUserOrganizationVo.setPassword(PasswordUtil.AESDecrypt(welfareUserOrganizationVo.getPassword()));
            }
        }
        return list;
    }


}
